package com.jy.adscm.zltx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyDept;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.system.mapper.mysql.JyDeptMapper;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import com.jy.adscm.zltx.bean.*;
import com.jy.adscm.zltx.mapper.mysql.*;
import com.jy.adscm.zltx.service.JyDrawingEditInfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 图纸修订记录 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-10-26
 */
@Service
public class JyDrawingEditInfoServiceImpl extends ServiceImpl<JyDrawingEditInfoMapper, JyDrawingEditInfo> implements JyDrawingEditInfoService {

    @Autowired
    JyDrawingEditInfoMapper jyDrawingEditInfoMapper;

    @Autowired
    JyDrawingListMapper jyDrawingListMapper;

    @Autowired
    JyDrawingAnnexMapper jyDrawingAnnexMapper;

    @Autowired
    JyDrawingAuditingMapper jyDrawingAuditingMapper;
    @Autowired
    JyDrawingTrainMapper jyDrawingTrainMapper;

    @Autowired
    JyUserMapper jyUserMapper;
    @Autowired
    JyDeptMapper jyDeptMapper;
    @Autowired
    JyDrawingRelationMapper jyDrawingRelationMapper;
    Logger logger = LoggerFactory.getLogger(getClass());
    @Value("${zltx.drawing.upload.formal-upload-path}")
    private  String formalUploadPath;
    @Value("${zltx.drawing.upload.history-upload-path}")
    private  String historyUploadPath;

    @Transactional
    @Override
    public void addAuditingEditInfo(JyDrawingEditInfo jyDrawingEditInfo) throws AdscmSystemException {
        logger.info("新增图纸修订记录...");
        JyDrawingList jyDrawingList = jyDrawingListMapper.selectById(jyDrawingEditInfo.getDrawingId());
        if (!AdscmBaseUtils.getInstance().isNotEmpty(jyDrawingEditInfo.getRelevantDept(),null)){
            if (!AdscmBaseUtils.getInstance().isNotEmpty(jyDrawingList.getRelevantDept(),null)){
                throw  new AdscmSystemException("请选择相关部门");
            }

         }
        jyDrawingEditInfoMapper.insert(jyDrawingEditInfo);

        //新增图纸修订记录成功后，将图纸修订记录上传的附件归属到图纸修订记录下，也就是将附件表中记录的drawing_id 由上传时存入的图纸ID ，改为 修订记录ID

        Long id = jyDrawingEditInfo.getId();
        Long drawingId = jyDrawingEditInfo.getDrawingId();

        Wrapper<JyDrawingAnnex> wrapper = new EntityWrapper<>();
        wrapper.eq("drawing_id",drawingId);
        wrapper.eq("annex_type",2);
        List<JyDrawingAnnex> annexes = jyDrawingAnnexMapper.selectList(wrapper);
        if (annexes != null && annexes.size()>0){
            for (JyDrawingAnnex annex : annexes) {
                annex.setDrawingId(id);
                jyDrawingAnnexMapper.updateById(annex);
            }
        }
        String relevantDept = jyDrawingEditInfo.getRelevantDept();//部门
        if (relevantDept != null && !"".equals(relevantDept)){
            String[] deptIds = relevantDept.split(",");
            if (deptIds != null && deptIds.length >0 ){
                for (String deptId : deptIds) {
                    JyDrawingAuditing auditing = new JyDrawingAuditing();
                    auditing.setAuditingDept(Integer.parseInt(deptId));
                    auditing.setDrawingEditId(jyDrawingEditInfo.getId());
                    jyDrawingAuditingMapper.insert(auditing);
                }
            }
        }

    }

    @Transactional
    @Override
    public void releaseEditInfo( Long id, JyUser user) throws AdscmSystemException {
        logger.info("发布修订记录...");

        //只有审核状态为审核通过，才可以发布修订记录，并且已经发布了，就不能再发布了
        JyDrawingEditInfo jyDrawingEditInfo = jyDrawingEditInfoMapper.selectById(id);

        if (jyDrawingEditInfo != null){
            Integer approvalResult = jyDrawingEditInfo.getApprovalResult();
            String drawingIsPublish = jyDrawingEditInfo.getDrawingIsPublish();

            if(approvalResult == 3 && !"1".equals(drawingIsPublish)){
                jyDrawingEditInfo.setDrawingIsPublish("1");
                jyDrawingEditInfo.setDrawingPublisher(user.getId());
                jyDrawingEditInfo.setDrawingPublishTime(new Date());
                jyDrawingEditInfo.setApprovalResult(5);
                jyDrawingEditInfoMapper.updateById(jyDrawingEditInfo);

                //发布成功后，将这个版本的记录，复制到正式版本中去
                Long drawingId = jyDrawingEditInfo.getDrawingId();


//                Wrapper<JyDrawingRelation> jyDrawingRelationWrapper=new EntityWrapper<>();
//                jyDrawingRelationWrapper.eq("drawing_id",drawingId);
//                List<JyDrawingRelation> jyDrawingRelations = jyDrawingRelationMapper.selectList(jyDrawingRelationWrapper);
//                for (JyDrawingRelation jyDrawingRelation : jyDrawingRelations) {
//                    JyDrawingList jyDrawingListRelation = jyDrawingListMapper.selectById(Long.valueOf(jyDrawingRelation.getRelationId()));
//                    jyDrawingListRelation.setDrawingPath(jyDrawingList.getDrawingPath());
//                    jyDrawingListMapper.updateById(jyDrawingListRelation);
//                }

                //获取所有修订记录
                Wrapper<JyDrawingEditInfo> wrapper = new EntityWrapper<>();
                wrapper.eq("drawing_id",drawingId);
                wrapper.eq("modify_content","初始版本");

                JyDrawingList drawingList = jyDrawingListMapper.selectById(drawingId);
                Integer count = jyDrawingEditInfoMapper.selectCount(wrapper);


                if (drawingList != null) {
                    if (count == 0){
                        //没有初始版本，那么在发布成功后，要修改原图纸记录的数据，并且，保存原图纸记录的最初版本

                        //先把原来那个PDF移动过来
                        AdscmBaseUtils.getInstance().moveFile(formalUploadPath + drawingList.getDrawingPath(),
                                historyUploadPath + drawingList.getDrawingPath());

                        JyDrawingEditInfo sourceDrawing = new JyDrawingEditInfo();
                        sourceDrawing.setDrawingId(drawingList.getId());
                        sourceDrawing.setDrawingName(drawingList.getDrawingName());
                        sourceDrawing.setDrawingCode(drawingList.getDrawingCode());
                        sourceDrawing.setDrawingPrice(drawingList.getDrawingPrice());
                        sourceDrawing.setDrawingRemark(drawingList.getDrawingRemark());
                        sourceDrawing.setDrawingVersion(drawingList.getDrawingVersion());
                        sourceDrawing.setTechnicsRemark(drawingList.getTechnicsRemark());
                        sourceDrawing.setModifiedDrawingPath(drawingList.getDrawingPath());
                        sourceDrawing.setModifyReason("初始版本");
                        sourceDrawing.setModifyContent("初始版本");
                        sourceDrawing.setModifyTime(drawingList.getCreateTime());
                        sourceDrawing.setModifier(drawingList.getDrawingCreater());
                        sourceDrawing.setApprovalResult(5);
                        sourceDrawing.setApprovalRemark(drawingList.getApprovalRemark());
                        sourceDrawing.setDrawingNeedTrain(drawingList.getDrawingNeedTrain());
                        sourceDrawing.setRelevantDept(drawingList.getRelevantDept());
                        sourceDrawing.setDrawingIsPublish("1");
                        sourceDrawing.setDrawingPublisher(drawingList.getDrawingCreater());
                        sourceDrawing.setDrawingPublishTime(drawingList.getCreateTime());

                        jyDrawingEditInfoMapper.insert(sourceDrawing);//保存初始版本
                        //把原来的附件也保存到这个【初始版本】中
                        Wrapper<JyDrawingAnnex> annexWrapper = new EntityWrapper<>();
                        annexWrapper.eq("drawing_id",drawingList.getId());
                        annexWrapper.eq("annex_type",1);
                        List<JyDrawingAnnex> jyDrawingAnnexes = jyDrawingAnnexMapper.selectList(annexWrapper);
                        if (jyDrawingAnnexes != null && jyDrawingAnnexes.size()>0){
                            for (JyDrawingAnnex jyDrawingAnnex : jyDrawingAnnexes) {
                                jyDrawingAnnex.setDrawingId(sourceDrawing.getId());
                                jyDrawingAnnex.setAnnexType(2);
                                jyDrawingAnnexMapper.updateById(jyDrawingAnnex);
                            }
                        }



                    }
                    //修改原图纸记录

                    //把新的图纸复制过去
                    AdscmBaseUtils.getInstance().copyFile(historyUploadPath + jyDrawingEditInfo.getModifiedDrawingPath(),
                            formalUploadPath + jyDrawingEditInfo.getModifiedDrawingPath());

                    drawingList.setDrawingName(jyDrawingEditInfo.getDrawingName());
                    drawingList.setDrawingCode(jyDrawingEditInfo.getDrawingCode());
                    drawingList.setDrawingPrice(jyDrawingEditInfo.getDrawingPrice());
                    drawingList.setDrawingRemark(jyDrawingEditInfo.getDrawingRemark());
                    drawingList.setDrawingVersion(jyDrawingEditInfo.getDrawingVersion());
                    drawingList.setTechnicsRemark(jyDrawingEditInfo.getTechnicsRemark());
                    drawingList.setDrawingPath(jyDrawingEditInfo.getModifiedDrawingPath());
                    drawingList.setChangeTimes((drawingList.getChangeTimes() == null ? 0 : drawingList.getChangeTimes()) + 1);
                    drawingList.setLastEditTime(new Date());
                    drawingList.setDrawingIsPublish("1");
                    drawingList.setDrawingPublisher(jyDrawingEditInfo.getDrawingPublisher());
                    drawingList.setDrawingPublishTime(jyDrawingEditInfo.getDrawingPublishTime());
                    drawingList.setRelevantDept(jyDrawingEditInfo.getRelevantDept());
                    drawingList.setDrawingNeedTrain(jyDrawingEditInfo.getDrawingNeedTrain());


                    jyDrawingListMapper.updateById(drawingList);

                    //删掉正式版中的附件
                    Wrapper<JyDrawingAnnex> annexWrapper2 = new EntityWrapper<>();
                    annexWrapper2.eq("drawing_id",drawingList.getId());
                    annexWrapper2.eq("annex_type",1);
                    jyDrawingAnnexMapper.delete(annexWrapper2);

                    //把这个版本的附件，复制一份给正式版
                    Wrapper<JyDrawingAnnex> annexWrapper1 = new EntityWrapper<>();
                    annexWrapper1.eq("drawing_id",jyDrawingEditInfo.getId());
                    annexWrapper1.eq("annex_type",2);
                    List<JyDrawingAnnex> annexes = jyDrawingAnnexMapper.selectList(annexWrapper1);
                    if (annexes != null && annexes.size()>0){
                        for (JyDrawingAnnex annex : annexes) {
                            JyDrawingAnnex temp = new JyDrawingAnnex();
                            temp.setAnnexType(1);
                            temp.setDrawingId(drawingList.getId());
                            temp.setAnnexPath(annex.getAnnexPath());
                            jyDrawingAnnexMapper.insert(temp);
                        }
                    }
                   //修改关联的图纸
                    Wrapper<JyDrawingRelation> jyDrawingRelationWrapper=new EntityWrapper<>();
                    jyDrawingRelationWrapper.eq("relation_id",drawingList.getId());
                    List<JyDrawingRelation> jyDrawingRelations = jyDrawingRelationMapper.selectList(jyDrawingRelationWrapper);
                    if (jyDrawingRelations.size()>0){
                        JyDrawingRelation relation = jyDrawingRelations.get(0);
                        Integer drawingId1 = relation.getDrawingId();
                        Wrapper<JyDrawingRelation> jyDrawingRelationWrapper1=new EntityWrapper<>();
                        jyDrawingRelationWrapper1.eq("drawing_id",drawingId1);
                        List<JyDrawingRelation> jyDrawingRelations1 = jyDrawingRelationMapper.selectList(jyDrawingRelationWrapper1);
                        for (JyDrawingRelation jyDrawingRelation : jyDrawingRelations1) {
                            JyDrawingList jyDrawingListRelation = jyDrawingListMapper.selectById(Long.valueOf(jyDrawingRelation.getRelationId()));
                            jyDrawingListRelation.setDrawingPath(drawingList.getDrawingPath());
                            jyDrawingListMapper.updateById(jyDrawingListRelation);
                        }
                    }

                }

                //如果需要培训，则生成待培训的记录
                String drawingNeedTrain = jyDrawingEditInfo.getDrawingNeedTrain();
                if ("1".equals(drawingNeedTrain)){
                    JyDrawingTrain train = new JyDrawingTrain();
                    train.setDrawingId(jyDrawingEditInfo.getDrawingId());
                    train.setDrawingEditId(jyDrawingEditInfo.getId());
                    train.setDrawingVersion(jyDrawingEditInfo.getDrawingVersion());

                    jyDrawingTrainMapper.insert(train);
                }


            }else {
                logger.error("当前状态，不能发布图纸");
                throw new AdscmSystemException("当前状态，不能发布图纸");
            }



        }else {
            logger.error("没有查询到【"+id+"】关联的修订");
            throw new AdscmSystemException("没有查询到【"+id+"】关联的修订");
        }


    }

    @Transactional
    @Override
    public void auditingEditInfo(JyDrawingEditInfo jyDrawingEditInfo) throws AdscmSystemException {

        logger.info("审核修订记录...");

        //如果审核未通过，则只改修订记录的内容
        Integer approvalResult = jyDrawingEditInfo.getApprovalResult();

        jyDrawingEditInfoMapper.updateById(jyDrawingEditInfo);

        if (approvalResult != 1){
            return;
        }

        //审核通过了，才有下面的这些

        JyDrawingEditInfo eInfo = jyDrawingEditInfoMapper.selectById(jyDrawingEditInfo.getId());
        Long drawingId = eInfo.getDrawingId();

        //获取所有修订记录
        Wrapper<JyDrawingEditInfo> wrapper = new EntityWrapper<>();
        wrapper.eq("drawing_id",drawingId);

        List<JyDrawingEditInfo> jyDrawingEditInfos = jyDrawingEditInfoMapper.selectList(wrapper);

        JyDrawingList drawingList = jyDrawingListMapper.selectById(drawingId);

        if (drawingList != null) {
            if (jyDrawingEditInfos != null && jyDrawingEditInfos.size() == 1 && jyDrawingEditInfos.get(0).getId() == jyDrawingEditInfo.getId()){
                //如果只有这一条修订记录，那么在审核通过后，不但要修改修订记录的审核状态，还要修改原图纸记录的数据，并且，保存原图纸记录的最初版本

                //先把原来那两个文件移动过来
                AdscmBaseUtils.getInstance().moveFile(formalUploadPath + drawingList.getDrawingPath(),
                        historyUploadPath + drawingList.getDrawingPath());
//                AdscmBaseUtils.getInstance().moveFile(formalUploadPath + drawingList.getInstructionsPath(),
//                        historyUploadPath + drawingList.getInstructionsPath());

                JyDrawingEditInfo sourceDrawing = new JyDrawingEditInfo();
                sourceDrawing.setDrawingId(drawingList.getId());
                sourceDrawing.setDrawingName(drawingList.getDrawingName());
                sourceDrawing.setDrawingCode(drawingList.getDrawingCode());
                sourceDrawing.setDrawingPrice(drawingList.getDrawingPrice());
                sourceDrawing.setDrawingRemark(drawingList.getDrawingRemark());
                sourceDrawing.setDrawingVersion(drawingList.getDrawingVersion());
                sourceDrawing.setTechnicsRemark(drawingList.getTechnicsRemark());
                sourceDrawing.setModifiedDrawingPath(drawingList.getDrawingPath());
//                sourceDrawing.setModifiedInstructionsPath(drawingList.getInstructionsPath());

                sourceDrawing.setModifyReason("初始版本");
                sourceDrawing.setModifyContent("初始版本");
                sourceDrawing.setModifyTime(drawingList.getCreateTime());
                sourceDrawing.setModifier(drawingList.getDrawingCreater());
                sourceDrawing.setApprovalResult(1);
//                sourceDrawing.setApprovalPerson(drawingList.getDrawingAuditor());
//                sourceDrawing.setApprovalTime(drawingList.getDrawingAuditTime());
                sourceDrawing.setApprovalRemark(drawingList.getApprovalRemark());

                jyDrawingEditInfoMapper.insert(sourceDrawing);//保存初始版本

            }
            //修改原图纸记录
            JyDrawingEditInfo editInfo = jyDrawingEditInfoMapper.selectById(jyDrawingEditInfo.getId());

            //把新的图纸复制过去
            AdscmBaseUtils.getInstance().copyFile(historyUploadPath + editInfo.getModifiedDrawingPath(),
                    formalUploadPath + editInfo.getModifiedDrawingPath());
//            AdscmBaseUtils.getInstance().copyFile(historyUploadPath + editInfo.getModifiedInstructionsPath(),
//                    formalUploadPath + editInfo.getModifiedInstructionsPath());

            drawingList.setDrawingName(editInfo.getDrawingName());
            drawingList.setDrawingCode(editInfo.getDrawingCode());
            drawingList.setDrawingPrice(editInfo.getDrawingPrice());
            drawingList.setDrawingRemark(editInfo.getDrawingRemark());
            drawingList.setDrawingVersion(editInfo.getDrawingVersion());
            drawingList.setTechnicsRemark(editInfo.getTechnicsRemark());
            drawingList.setDrawingPath(editInfo.getModifiedDrawingPath());
//            drawingList.setInstructionsPath(editInfo.getModifiedInstructionsPath());
            drawingList.setChangeTimes((drawingList.getChangeTimes() == null ? 0 : drawingList.getChangeTimes()) + 1);
            drawingList.setLastEditTime(new Date());

//            drawingList.setDrawingAuditor(jyDrawingEditInfo.getApprovalPerson());
//            drawingList.setDrawingAuditTime(jyDrawingEditInfo.getApprovalTime());
            drawingList.setApprovalRemark(jyDrawingEditInfo.getApprovalRemark());
//            drawingList.setAuditPass(jyDrawingEditInfo.getApprovalResult()+"");

            jyDrawingListMapper.updateById(drawingList);


        }else {
            throw new AdscmSystemException("没有查询到关联的图纸记录");
        }

    }


    @Override
    public List<JyDrawingEditInfo> selectByDrawingId(Long drawingId) throws AdscmSystemException {

        logger.info("根据图纸ID，查询修订记录...");
        Wrapper<JyDrawingEditInfo> wrapper = new EntityWrapper<>();
        wrapper.eq("drawing_id",drawingId);
        wrapper.orderBy("modify_time");

        List<JyDrawingEditInfo> jyDrawingEditInfos = jyDrawingEditInfoMapper.selectList(wrapper);

        if (jyDrawingEditInfos != null && jyDrawingEditInfos.size()>0){
            for (JyDrawingEditInfo jyDrawingEditInfo : jyDrawingEditInfos) {
                Integer modifier = jyDrawingEditInfo.getModifier();
                Integer drawingPublisher = jyDrawingEditInfo.getDrawingPublisher();

                if (modifier != null ){
                    JyUser user = jyUserMapper.selectById(modifier);
                    if (user != null){
                        jyDrawingEditInfo.setModifierName(user.getName());
                    }

                }
                if (drawingPublisher != null ){
                    JyUser user = jyUserMapper.selectById(drawingPublisher);
                    if (user != null){
                        jyDrawingEditInfo.setDrawingPublisher_name(user.getName());
                    }

                }

                //查询附件集合
                Wrapper<JyDrawingAnnex> annexWrapper = new EntityWrapper<>();
                annexWrapper.eq("drawing_id",jyDrawingEditInfo.getId());
                annexWrapper.eq("annex_type",2);
                List<JyDrawingAnnex> jyDrawingAnnexes = jyDrawingAnnexMapper.selectList(annexWrapper);

                jyDrawingEditInfo.setAnnexes(jyDrawingAnnexes);

                //查询审核集合
                Wrapper<JyDrawingAuditing> auditWrapper = new EntityWrapper<>();
                auditWrapper.eq("drawing_edit_id",jyDrawingEditInfo.getId());
                List<JyDrawingAuditing> jyDrawingAuditings = jyDrawingAuditingMapper.selectList(auditWrapper);
                if (jyDrawingAuditings != null && jyDrawingAuditings.size()>0){
                    for (JyDrawingAuditing auditing : jyDrawingAuditings) {
                        Integer auditor = auditing.getAuditor();
                        Integer auditingDept = auditing.getAuditingDept();
                        if (auditor != null ){
                            JyUser user = jyUserMapper.selectById(auditor);
                            if (user != null){
                                auditing.setAuditorName(user.getName());
                            }

                        }
                        if (auditingDept != null ){
                            JyDept dept = jyDeptMapper.selectById(auditingDept);
                            if (dept != null){
                                auditing.setAuditingDeptName(dept.getDeptName());
                            }
                        }

                    }
                }

                jyDrawingEditInfo.setAuditings(jyDrawingAuditings);

            }
        }


        return jyDrawingEditInfos;
    }

    @Override
    public JyDrawingEditInfo selectLastOrNext(Long currentId, String type) throws AdscmSystemException {

        logger.info("获取上一条或者下一条记录...");

        if (currentId != null){
            List<JyDrawingEditInfo> drawingEditList = jyDrawingEditInfoMapper.getDrawingEditList(currentId);

            JyDrawingEditInfo drawingEdit = null;

            for (int i = 0;drawingEditList != null && i < drawingEditList.size() ;i++) {
                JyDrawingEditInfo temp = drawingEditList.get(i);

                if ("next".equals(type) && currentId == temp.getId()){
                    if ((i + 1) == drawingEditList.size()){
                        drawingEdit = drawingEditList.get(0);
                    }else {
                        drawingEdit = drawingEditList.get(i + 1);
                    }
                    break;
                }else if ("last".equals(type) && currentId == temp.getId()){
                    if(i == 0){
                        drawingEdit = drawingEditList.get(drawingEditList.size() - 1);
                    }else {
                        drawingEdit = drawingEditList.get(i - 1);
                    }
                }

            }

            Integer modifier = drawingEdit.getModifier();
            Integer approvalPerson = drawingEdit.getApprovalPerson();

            if (modifier != null ){
                JyUser user = jyUserMapper.selectById(modifier);
                if (user != null){
                    drawingEdit.setModifierName(user.getName());
                }

            }
            if (approvalPerson != null ){
                JyUser user = jyUserMapper.selectById(approvalPerson);
                if (user != null){
                    drawingEdit.setApprovalPersonName(user.getName());
                }

            }

            return drawingEdit;
        }else {
            throw new AdscmSystemException("参数 id 为null");
        }
    }

    @Override
    public String selectLastVersion(Long currentId) throws AdscmSystemException {

        String filePath = null;

        if (currentId != null){
            List<JyDrawingEditInfo> drawingEditList = jyDrawingEditInfoMapper.getDrawingEditList(currentId);

            if(drawingEditList != null && drawingEditList.size() == 1){
                //只有一条，获取原版
                Long drawingId = drawingEditList.get(0).getDrawingId();

                JyDrawingList jyDrawingList = jyDrawingListMapper.selectById(drawingId);

                filePath = formalUploadPath + File.separator + jyDrawingList.getDrawingPath();

            }else {
                for (int i = 0;  i < drawingEditList.size() ;i++) {
                    JyDrawingEditInfo temp = drawingEditList.get(i);
                    if(currentId == temp.getId()){
                        if(i == 0){
                            //第一条，就还是和原版比
                            Long drawingId = temp.getDrawingId();
                            JyDrawingList jyDrawingList = jyDrawingListMapper.selectById(drawingId);
                            filePath = formalUploadPath + File.separator + jyDrawingList.getDrawingPath();
                        }else {
                            filePath = historyUploadPath + File.separator + drawingEditList.get(i - 1).getModifiedDrawingPath();
                        }
                        break;
                    }
                }
            }

        }

        return filePath;
    }
}
